package io.lkt.modules.sys.controller;

import io.lkt.common.util.Query;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.R;
import io.lkt.modules.sys.entity.BBrandVitalEntity;
import io.lkt.modules.sys.entity.BOrderVitalEntity;
import io.lkt.modules.sys.entity.SysUserEntity;
import io.lkt.modules.sys.service.BBrandInfoService;
import io.lkt.modules.sys.service.BOrderInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/sys/brandvital")
public class BBrandVitalController extends AbstractController{
    @Autowired
    private BBrandInfoService bBrandInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:bbrandinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        if(params.get("gzhCode") == null || params.get("gzhCode").toString().trim().equals("")) {
            return R.ok();
        }
        System.out.println(params);
        SysUserEntity curUser= getUser();
        params.put("curUserId",curUser.getUserId());

        if(params.get("startDate")!=null && !params.get("startDate").toString().trim().equals("")) {
            params.put("startDate", params.get("startDate"));
        }
        if(params.get("endDate")!=null && !params.get("endDate").toString().trim().equals("")) {
            params.put("endDate", params.get("endDate")+" 23:59:59");
        }

        Query query = new Query(params);

        List<BBrandVitalEntity> list=bBrandInfoService.queryVital(query);
        Integer total=bBrandInfoService.queryVitelTotal(query);
        PageUtils page = new PageUtils(list, total, query.getLimit(), query.getPage());

        return R.ok().put("page", page);
    }



}
